package order.controller;


import common.Resquest;
import order.service.OrderServices;
import org.springframework.web.bind.annotation.*;
import resgistor.Video;

import javax.annotation.Resource;
import java.util.Objects;

@RestController
@RequestMapping("/api/order/c")
public class OrderController {
    @Resource
    OrderServices service;
    @Resource
    Resquest resquest;


    @GetMapping("/addVideoOrder")
    public Resquest addVideoOrder(@RequestParam("id") Integer id ,@RequestParam("title") String videoTitle){
        System.out.println(videoTitle);
        System.out.println(id);
        if(Objects.nonNull(id)){
            System.out.println("kk");
            return service.addVideoOrder(id,videoTitle);
        }
        return resquest.error(401, "失败");
    }

    @GetMapping("/searchOrder")
    public Object searchOrder(@RequestParam("id") Integer id,@RequestParam("title") String videoTitle) {

            return service.searchOrder(id,videoTitle);


    }

    @PostMapping("/addVideoOrder2")
    Resquest addVideoOrder2(@RequestBody Video video) throws InterruptedException {
        if(Objects.nonNull(video.getId())){

            return service.addVideoOrder2(video.getId(),video.getTitle());
        }
        return resquest.error(401, "失败");
    }


}
